<!doctype html>
<html>
<head>
    <meta charset="UTF-8"/>
    <title>成库个数</title>
    <link rel="stylesheet" type="text/css" href="/webapp/css/easyui.css">
    <link rel="stylesheet" type="text/css" href="/webapp/css/icon.css">
    <link rel="stylesheet" type="text/css" href="/webapp/css/color.css">
    <link rel="stylesheet" type="text/css" href="/webapp/css/public.css">
    <script type="text/javascript" src="/webapp/js/lib/jquery.min.js"></script>
    <script type="text/javascript" src="/webapp/js/lib/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/webapp/js/lib/jquery.global.settings.js"></script>
    <script type="text/javascript" src="/webapp/js/lib/ajaxfileupload.js"></script>
    <script type="text/javascript" src="/webapp/js/common/config.js"></script>
</head>
<body>
<div class="easyui-container-fluid">
    <div class="easyui-panel" style="border: none;">
        <div class="nav" id="nav"></div>
        <div class="easyui-panel" style="border:none;">
            <form id="ff" method="post">
                <div style="margin-bottom: 20px;">
                    <label class="item-label">年：</label>
                    <input type="text" id="year" name="year" class="easyui-combobox" data-options="required:true" required="required" style="width: 100px;"/>
                    <span id="monthLabel">
                        <label class="item-label">月：</label>
                        <input type="text" id="month" name="month" class="easyui-combobox" data-options="required:true" required="required" style="width: 100px;">
                        </span>
                    <span id="weekLabel">
                        <label class="item-label">周：</label>
                        <input type="text" id="week" name="week" class="easyui-combobox" data-options="required:true" required="required" style="width: 100px;">
                            </span>
                    <a href="javascript:void(0);" class="easyui-linkbutton c8" onclick="searchBy()" style="width:80px;margin-left: 40px;">查询</a>
                </div>
            </form>
        </div>
        <div class="table-wrapper">
            <table id="datagrid" data-options="fitColumns:true,scrollBarSize:0">
                <thead>
                <tr>
                    <th data-options="field:'categoryCode',align:'center'" width="100">品类码</th>
                    <th data-options="field:'categoryName',align:'center'" width="100">品类名</th>
                    <th data-options="field:'time',align:'center'" width="100">成库时间</th>
                    <th data-options="field:'status',align:'center'" width="100">成库状态</th>

                </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    function initPage() {
        $.when(initMonthWeek("monthLabel","weekLabel"),initCategorySelect("categorySelect")).done(function () {
            searchBy();
        });
    }
    $(function(){
        var height = $(window).height();
        var nav_height = $("#nav")._outerHeight();
        var ff_height = $("#ff").height();
        var table_height = height-nav_height-ff_height-40;
        $("#datagrid").css("max-height",table_height);
        $("#datagrid").datagrid({
            rownumbers:true,
            pagination:true,
            idField:"id",
            checkOnSelect:false,
            toolbar:[{
                text:'配置',
                handler:function(){
                    var year = getFormData(document.getElementById("ff")).year;
                    var month = getFormData(document.getElementById("ff")).month;
                    var week = getFormData(document.getElementById("ff")).week;
                    if(year){
                        window.parent.addTab("配置","/webapp/pages/product/statisticsPc/add.html?year="+year+"&month="+month+"&week="+week);
                    }else{
                        $.messager.alert("提示","请选择品类","warn");
                    }
                }
            }]
        }).datagrid("getPager").pagination({
            onSelectPage:searchBy
        });
        aRecords("成库个数","/webapp/pages/product/statisticsPc")
        initPage();
    });

    function searchBy(page,size) {
        var dtd = $.Deferred();
        var data = getFormData(document.getElementById("ff"));
        data.reportType=window.parent.workMode.toUpperCase();
        var pager = {page:page,size:size};
        var jsonobj = {};
        jsonobj = $.extend(true,jsonobj,transfer(data));
        jsonobj = JSON.stringify(jsonobj);
        $.ajax({
            url:config.url + "/statisticsPc/page",
            type:'post',
            data:jsonobj,
            contentType:"application/json;charset=UTF-8",
            dataType:'json',
            xhrFields:{withCredentials:true},
            beforeSend:function () {
                $.messager.progress({
                    title:"请稍等",
                    interval:50,
                    text:"数据加载中..."
                });
            },
            complete:function () {
                $.messager.progress("close");
            },
            success:function (data) {
                $.messager.progress("close");
                if(data){
                    globalData = data;
                    $("#datagrid").datagrid("loadData",data);
                    dtd.resolve();
                }
            },
            error:function (XMLHttpRequest,textStatus,errorThrown) {

            }
        });
        return dtd.promise();
    }
    $("#ff").keydown(function (event) {
        var e = event || window.event;
        var keyCode = e.keyCode || e.which;
        if(keyCode=="13"){
            searchBy();
        }
    });
</script>

</html>
